﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using qlHieuThuocDongY.DataAccess;

namespace qlHieuThuocDongY
{
    public partial class frmTimKiemBenhNhan : Form
    {
        public frmTimKiemBenhNhan()
        {
            InitializeComponent();
        }

        ConnectData conn = new ConnectData();
        private void frmTimKiemBenhNhan_Load(object sender, EventArgs e)
        {
            dataGridViewTimKiemThongTinBenhNhan.DataSource = conn.GetDataTable("Select * from ThongTinBenhNhan");

        }

        private void txtNhapTimKiemBN_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtNhapTimKiemBN.Text.Length == 0)
                dataGridViewTimKiemThongTinBenhNhan.DataSource = conn.GetDataTable("Select * from ThongTinBenhNhan");
            else
            {
                if (rdMaBN.Checked)
                    dataGridViewTimKiemThongTinBenhNhan.DataSource = conn.GetDataTable("Select * from ThongTinBenhNhan where MaBN='" + txtNhapTimKiemBN.Text + "'");
                else
                    dataGridViewTimKiemThongTinBenhNhan.DataSource = conn.GetDataTable("Select * from ThongTinBenhNhan where TenBN like N'%" + txtNhapTimKiemBN.Text + "%'");
            }

        }


    }
}
